//
//  NewSellerOrderScrollTableViewCell.m
//  智积分
//
//  Created by apple on 2018/5/15.
//  Copyright © 2018年 Cynic. All rights reserved.
//

#import "NewSellerOrderScrollTableViewCell.h"

@interface NewSellerOrderScrollTableViewCell()<UIScrollViewDelegate>
@property (nonatomic ,retain)NSMutableArray *scrollData;
@end
@implementation NewSellerOrderScrollTableViewCell


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(NSMutableArray *)scrollData{
    if (!_scrollData) {
        _scrollData = [NSMutableArray array];
    }
    return _scrollData;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    _scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, cx_wid, cx_wid / 378 * 185)];
    _scroll.delegate = self;
    _scroll.contentSize = CGSizeMake(cx_wid, cx_wid / 378 * 185);
    UIView *bgview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cx_wid, cx_wid / 378 * 185)];
    [self.contentView addSubview:bgview];
    bgview.backgroundColor = [UIColor whiteColor];
    _topBG = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cx_wid, cx_wid / 378 * 185)];
    _topBG.backgroundColor = [UIColor clearColor];
    CGFloat leftdis = 20.0 / 378 * cx_wid;
    CGFloat topdis = 12.0 / 20 * leftdis;
    UIImageView *coverview = [[UIImageView alloc] initWithFrame:CGRectMake(leftdis, topdis, cx_wid - leftdis * 2, cx_wid / 378 * 185 - topdis * 2)];
    coverview.image = [UIImage imageNamed:@"MoneyBG"];
    [self.contentView addSubview:coverview];
    [_scroll addSubview:_topBG];
    [self.contentView addSubview:_scroll];
    UIView *bottmlayer = [[UIView alloc] initWithFrame:CGRectMake(0, cx_wid / 378 * 185, cx_wid, 10)];
    bottmlayer.backgroundColor = [CXSinglerModel colorWithHex:@"f3f4f6" alpha:1];
    [self.contentView addSubview:bottmlayer];
//    if ([reuseIdentifier isEqual:@"firstnewsellerorderscrollcellIndentifier"]) {
        UILabel *centertitle = [[UILabel alloc] initWithFrame:CGRectMake(20, [self RealHit:24], cx_wid - 40, 16)];
        centertitle.text = @"今日营业额(元)";
        centertitle.font = [UIFont systemFontOfSize:14];
        _money = [[UILabel alloc] initWithFrame:CGRectMake(20, [self RealHit:59], cx_wid - 40, 40)];
    _money.text = @"0.00";
        _money.font =[ UIFont systemFontOfSize:36];
        _money.textColor = centertitle.textColor = [UIColor whiteColor];
        centertitle.textAlignment = _money.textAlignment = NSTextAlignmentCenter;
        [_topBG addSubview:_money];
        [_topBG addSubview:centertitle];
        NSArray *dess = @[@"付款订单数",@"付款件数"];
    if ([reuseIdentifier isEqual:@"firstnewsellerorderscrollcellIndentifier"]) {
        dess  = @[@"交易笔数",@"顾客人数"];
    }
        for (NSInteger index = 0; index < dess.count; index ++) {
            UILabel *partlabel = [[UILabel alloc] initWithFrame:CGRectMake((1.0 + 2 * index) / 4 * coverview.bounds.size.width - 60 + leftdis, [self RealHit:111], 120, 20)];
            partlabel.font = [UIFont systemFontOfSize:20];
            UILabel *deslabel = [[UILabel alloc] initWithFrame:CGRectMake((1.0 + 2 * index) / 4 * coverview.bounds.size.width - 60 + leftdis, [self RealHit:136], 120, 18)];
            deslabel.font = [UIFont systemFontOfSize:13];
            deslabel.text = dess[index];
            partlabel.textColor = deslabel.textColor = [UIColor whiteColor];
            deslabel.textAlignment = partlabel.textAlignment = NSTextAlignmentCenter;
            if (index == 0) {
                _ordersNum = partlabel;
                _ordersNum.text = @"0.00";
            }
            else{
                _dealsNum = partlabel;
                _dealsNum.text = @"0.00";
            }
            [_topBG addSubview:partlabel];
            [_topBG addSubview:deslabel];
        }
//    }
    if (self){//[reuseIdentifier isEqual:@"secondnewsellerorderscrollcellIndentifier"]
        
        UIButton *searchBtn = [[UIButton alloc]initWithFrame:CGRectMake(cx_wid - [self RealHit:98], [self RealHit:64], 31, 31)];
        [searchBtn setImage:[UIImage imageNamed:@"icon_look"] forState:UIControlStateNormal];
        [_topBG addSubview:searchBtn];
        WEAKSELF;
        [searchBtn cx_eventsBlockHandler:^{
            weakSelf.topBG.hidden = YES;
            weakSelf.bottomBG.hidden = NO;
        } forControlEvents:UIControlEventTouchUpInside];
        _bottomBG = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cx_wid, cx_wid / 378 * 185)];
        _bottomBG.hidden = YES;
        [self.contentView addSubview:_bottomBG];
        /*@property (nonatomic ,retain)UIButton *popBtn;
         @property (nonatomic ,retain)UILabel *TodayRiseMoney;
         @property (nonatomic ,retain)UILabel *TodayRiseCode;*/
        _popBtn = [[UIButton alloc] initWithFrame:CGRectMake([self RealHit:33] - 10, [self RealHit:23] - 10, 36, 36)];
        UIImageView *popimg = [[UIImageView alloc] initWithFrame:CGRectMake([self RealHit:33], [self RealHit:23], 16, 16)];
        popimg.image = [UIImage imageNamed:@"icon_return"];
//        [_popBtn setImage:[UIImage imageNamed:@"icon_return"] forState:UIControlStateNormal];
        [_popBtn cx_eventsBlockHandler:^{
            weakSelf.bottomBG.hidden = YES;
            weakSelf.topBG.hidden = NO;
        } forControlEvents:UIControlEventTouchUpInside];
        [_bottomBG addSubview:_popBtn];
        [_bottomBG addSubview:popimg];
        NSArray *names = @[@"今日收入现金(元)",@"今日收入积分"];
        for (NSInteger index = 0; index < names.count; index ++) {
            UILabel *numlabel = [[UILabel alloc] initWithFrame:CGRectMake((1.0 + 2 * index) / 4 * coverview.bounds.size.width - 60 + leftdis, [self RealHit:67], 120, 28)];
            UILabel *deslabel = [[UILabel alloc] initWithFrame:CGRectMake((1.0 + 2 * index) / 4 * coverview.bounds.size.width - 60 + leftdis, [self RealHit:99], 120, 16)];
            numlabel.font = [UIFont systemFontOfSize:28];
            deslabel.font = [UIFont systemFontOfSize:14];
            numlabel.textAlignment = deslabel.textAlignment = NSTextAlignmentCenter;
            deslabel.text = names[index];
            deslabel.textColor = numlabel.textColor = [UIColor whiteColor];
            if (index == 0) {
                _TodayRiseMoney = numlabel;
            }
            else{
                _TodayRiseCode = numlabel;
            }
            [_bottomBG addSubview:numlabel];
            [_bottomBG addSubview:deslabel];
            
        }
        
    }
//    else if ([reuseIdentifier isEqual:@"thirdnewsellerorderscrollcellIndentifier"]){
    
//    }
//    else if ([reuseIdentifier isEqual:@"fourthnewsellerorderscrollcellIndentifier"]){
    
//    }
    return self;
}



/**
 比例计算实际高度

 @param basehit ui图中的尺寸
 @return 比例计算的尺寸
 */
-(CGFloat)RealHit:(CGFloat)basehit{
    return basehit / 185 * (cx_wid / 378 * 185);
}






@end
